package com.opta.entity;

import org.optaplanner.core.api.domain.entity.PlanningEntity;
import org.optaplanner.core.api.domain.valuerange.ValueRangeProvider;
import org.optaplanner.core.api.domain.variable.PlanningVariable;

import javax.swing.*;
import java.io.Serializable;
import java.sql.ClientInfoStatus;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * 2 * @Author: GuanChong
 * 3 * @Date: 2020/10/12 9:11
 * 4 * @Desc: 代排任务实体（规划实体） 待排任务
 */
@PlanningEntity
public class TaskOrder implements Serializable {
    /**
     * 工序
     */
    public String workProcedure;
    /**
     * 订单ID
     */
    public String orderId;
    /**
     * 序号
     */
    public Integer seq;
    /**
     * 需求类型
     */
    public String demandType;
    /**
     * 机型集合 （物料编码、bom、机型、版面）
     */
    public ModelInfo modelInfos;
    /**
     * 订单量
     */
    public Integer orderQty;
    /**
     * 排程量
     */
    public Integer schedulingQty;
    /**
     * 工厂
     */
    public String werks;
    /**
     * 交货日期
     */
    public LocalDate deliveryDate;
    /**
     * 最早开始时间
     */
    public LocalDate earliestStartTime;
    /**
     * 最晚开始时间
     */
    public LocalDate latestStartTime;
    /**
     * 下单时间
     */
    public LocalDate orderDate;
    /**
     * 整机机型
     */
    public String wholeModelCode;
    /**
     * 版型
     */
    public String templateType;
    /**
     * 产品线
     */
    public String productLine;
    /**
     * 客户
     */
    public String customer;
    /**
     * 阶段
     */
    public String stage;
    /**
     * 是否成品
     */
    public Boolean finishedProduct;
    /**
     * 已排线体
     */
    public Line line;

    /**
     * @return
     */

    public Integer sdQty;

    @PlanningVariable(valueRangeProviderRefs = {"qtyRange"})
    public Integer getSdQty() {
        return sdQty;
    }

    @ValueRangeProvider(id = "qtyRange")
    public List<Integer> getUsageQtyRange() {
        List<Integer> list = new ArrayList<>(2);
        for (Integer i = 0; i < this.orderQty + 1; i++) {
            list.add(i);
        }
        return list;
    }


    public void setSdQty(Integer sdQty) {
        this.sdQty = sdQty;
    }

    public String getWorkProcedure() {
        return workProcedure;
    }

    public void setWorkProcedure(String workProcedure) {
        this.workProcedure = workProcedure;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public Integer getSeq() {
        return seq;
    }

    public void setSeq(Integer seq) {
        this.seq = seq;
    }

    public String getDemandType() {
        return demandType;
    }

    public void setDemandType(String demandType) {
        this.demandType = demandType;
    }

    public ModelInfo getModelInfos() {
        return modelInfos;
    }

    public void setModelInfos(ModelInfo modelInfos) {
        this.modelInfos = modelInfos;
    }

    public Integer getOrderQty() {
        return orderQty;
    }

    public void setOrderQty(Integer orderQty) {
        this.orderQty = orderQty;
    }

    public Integer getSchedulingQty() {
        return schedulingQty;
    }

    public void setSchedulingQty(Integer schedulingQty) {
        this.schedulingQty = schedulingQty;
    }

    public String getWerks() {
        return werks;
    }

    public void setWerks(String werks) {
        this.werks = werks;
    }

    public LocalDate getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(LocalDate deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    public LocalDate getEarliestStartTime() {
        return earliestStartTime;
    }

    public void setEarliestStartTime(LocalDate earliestStartTime) {
        this.earliestStartTime = earliestStartTime;
    }

    public LocalDate getLatestStartTime() {
        return latestStartTime;
    }

    public void setLatestStartTime(LocalDate latestStartTime) {
        this.latestStartTime = latestStartTime;
    }

    public LocalDate getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(LocalDate orderDate) {
        this.orderDate = orderDate;
    }

    public String getWholeModelCode() {
        return wholeModelCode;
    }

    public void setWholeModelCode(String wholeModelCode) {
        this.wholeModelCode = wholeModelCode;
    }

    public String getTemplateType() {
        return templateType;
    }

    public void setTemplateType(String templateType) {
        this.templateType = templateType;
    }

    public String getProductLine() {
        return productLine;
    }

    public void setProductLine(String productLine) {
        this.productLine = productLine;
    }

    public String getCustomer() {
        return customer;
    }

    public void setCustomer(String customer) {
        this.customer = customer;
    }

    public String getStage() {
        return stage;
    }

    public void setStage(String stage) {
        this.stage = stage;
    }

    public Boolean getFinishedProduct() {
        return finishedProduct;
    }

    public void setFinishedProduct(Boolean finishedProduct) {
        this.finishedProduct = finishedProduct;
    }

    @PlanningVariable(valueRangeProviderRefs = {"teamRange"})
    public Line getLine() {
        return line;
    }

    public void setLine(Line line) {
        this.line = line;
    }

    @Override
    public String toString() {
        return "TaskOrder{" +
                "workProcedure='" + workProcedure + '\'' +
                ", orderId='" + orderId + '\'' +
                ", seq=" + seq +
                ", demandType='" + demandType + '\'' +
                ", modelInfos=" + modelInfos +
                ", orderQty=" + orderQty +
                ", schedulingQty=" + schedulingQty +
                ", werks='" + werks + '\'' +
                ", deliveryDate=" + deliveryDate +
                ", earliestStartTime=" + earliestStartTime +
                ", latestStartTime=" + latestStartTime +
                ", orderDate=" + orderDate +
                ", wholeModelCode='" + wholeModelCode + '\'' +
                ", templateType='" + templateType + '\'' +
                ", productLine='" + productLine + '\'' +
                ", customer='" + customer + '\'' +
                ", stage='" + stage + '\'' +
                ", finishedProduct=" + finishedProduct +
                ", line=" + line +
                ", sdQty=" + sdQty +
                '}';
    }
}
